# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: games-engines/anura/anura-9999.ebuild 2014/05/14 15:30:00 itspec.ru Exp $

EAPI="3"

inherit eutils git-2 games flag-o-matic

DESCRIPTION="Anura is the tech behind the spectacular [Frogatto & Friends]"
HOMEPAGE="http://frogatto.com/"
EGIT_REPO_URI="https://github.com/anura-engine/anura.git"

LICENSE="GPL-2 free-noncomm"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

IUSE_MODULES="hex iso lib_2d phydemo projection_test"

DEPEND="dev-libs/boost
        media-libs/glew
        >=media-libs/glm-0.9.3.2
        media-libs/libpng:0
        media-libs/libsdl2[X,sound,joystick,opengl,video]
        media-libs/sdl2-image[png]
        media-libs/sdl2-mixer[vorbis]
        media-libs/sdl2-ttf
        sys-libs/zlib
        virtual/opengl
        virtual/glu"

RDEPEND="${DEPEND}"

for module in ${IUSE_MODULES} ; do
    IUSE+=" anura_modules_${module}"
done
unset module

src_unpack() {
    git-2_src_unpack
}

src_compile() {
    emake USE_CCACHE="no" || die
}

src_install() {
    dodoc INSTALL LICENSE README.md

    insinto "${GAMES_DATADIR}/${PN}"
    doins -r data images music || die

    insinto "${GAMES_DATADIR}/${PN}/modules"
    for x in ${IUSE_MODULES} ; do
        if has ${x} ${ANURA_MODULES}; then
            doins -r modules/${x} || die
        fi
    done

    exeinto "${GAMES_DATADIR}/${PN}"
    doexe ${PN}
    prepgamesdirs
}

pkg_postinst() {
    elog
    elog "To install addition modules you must add next changes to /etc/make.conf:"
    elog "1. add line"
    elog "\`USE_EXPAND=\"\${USE_EXPAND} ANURA_MODULES\"\`"
    elog
    elog "2. define list of required modules in ANURA_MODULES variable like this:"
    elog "\`ANURA_MODULES=\"hex icons iso lib_2d phydemo projection_test\"\`"
    elog
}
